package com.tengju.user.domain.model.sms;

import lombok.AllArgsConstructor;

import java.util.List;

/**
 * @author wuziyang
 */
@AllArgsConstructor
public enum OperationType {

    /**
     * 通用客户端校验验证码
     */
    CHECK_CODE(9999,"通用校验验证码"),

    /**
     * 登陆
     */
    LOGIN(1,"登陆"),
    /**
     * 密码变更
     */
    PASSWORD_CHANGE(2,"密码变更"),
    /**
     * 个人身份验证
     */
    PERSONAL_AUTH(3,"个人身份验证"),
    /**
     * 个人签约
     */
    PERSONAL_SIGN(4,"个人签约"),
    /**
     * 修改收款账户
     */
    MODIFY_ACCOUNT(5,"修改收款账户"),
    /**
     * 注册乐税个体户
     */
    REGISTER_LE_TAX_ACCOUNT(6,"注册乐税个体户"),
    /**
     * 解绑收款
     */
    UNBIND_ACCOUNT(7,"解绑收款"),
    /**
     * 自认证
     */
    SELF_CERTIFICATION(8,"自认证"),
    ;

    private Integer val;
    private String desc;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public static OperationType fromVal(Integer val) {
        for (OperationType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }


    public static OperationType fromName(String name) {
        for (OperationType type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }

    public static List<OperationType> getAll(){
        return List.of(CHECK_CODE,LOGIN,PASSWORD_CHANGE,PERSONAL_AUTH,PERSONAL_SIGN,MODIFY_ACCOUNT,REGISTER_LE_TAX_ACCOUNT,UNBIND_ACCOUNT);
    }
}
